package User

import (
	"GORM_Demo04/part11/dbope"
	"GORM_Demo04/part11/pojo"
	"fmt"
	"github.com/gin-gonic/gin"
)

/**
*处理的业务逻辑
 */
func SubmitUser(context *gin.Context) {
	uname := context.PostForm("uname")
	password := context.PostForm("password")
	fmt.Println(uname + "---------" + password)

	user := pojo.User{
		UName:    uname,
		Password: password,
	}

	fmt.Println(user)

	defer dbope.Db.Close()

	flog := dbope.Db.HasTable(&pojo.User{})

	if flog == false {
		dbope.Db.CreateTable(&pojo.User{})
	}

	dbope.Db.Create(&user)

	context.HTML(200, "demo01/user.html", gin.H{
		"user": user,
	})
}
